Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concurrency control parameters #144

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

ccampo133
Copy link
Contributor

@ccampo133 ccampo133 commented Aug 27, 2024

Description of the change

This PR adds some concurrency control parameters which can be useful to tweaking performance/resource usage and dealing with long-running queries.

Type of change

  • Bug fix (non-breaking change that fixes an issue).
  • New feature (non-breaking change that adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklists

Development

  • Lint rules pass locally.
  • The code changed/added as part of this pull request has been covered with tests.
  • All tests related to the changed code pass.

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached.
  • Jira issue referenced in commit message and/or PR title.

Testing

Unit and manual testing.

@ccampo133 ccampo133 force-pushed the add_concurrency_control_params branch 2 times, most recently from deee4d2 to 7c1799f Compare August 27, 2024 17:12
@ccampo133 ccampo133 force-pushed the add_concurrency_control_params branch from 7c1799f to ce8478f Compare August 27, 2024 17:12
Copy link

@yoursnerdly yoursnerdly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - please consider the minor comments.

sql/scanner.go Outdated
Comment on lines 228 to 232
if sema != nil {
// Release the slot once the goroutine is done.
sema.Release(1)
}
wg.Done()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done in a deferred call for more safety (from premature returns like the one you had earlier in case of ctx.Done()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function currently can't actually, return early, so the effect is the same, but I will add it to a defer just to to make it more resilient to possible future changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addr bb28f86

// database handles (one per database).
var sema *semaphore.Weighted
if s.config.RepoConfig.MaxOpenConns > 0 {
sema = semaphore.NewWeighted(int64(s.config.RepoConfig.MaxOpenConns))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we now doing with MaxOpenConns (is it needed any longer)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is still needed. It eventually gets passed all the way down to the sql.DB instance - see: https://github.com/cyralinc/dmap/blob/main/sql/generic.go#L243

This ultimately means that the number of concurrent queries for a single database will be min(MaxOpenConns, MaxConcurrency), since all queries to a database use the same sql.DB instance.

Copy link

@yoursnerdly yoursnerdly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I thought I had approved earlier.

@ccampo133 ccampo133 merged commit 087671d into cyralinc:main Aug 28, 2024
3 checks passed
@ccampo133 ccampo133 deleted the add_concurrency_control_params branch August 28, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants